package com.baizhi.action;

import com.baizhi.entity.AuctionRecord;
import com.baizhi.service.AuctionRecordService;
import com.baizhi.service.AuctionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@Scope("prototype")
public class AuctionRecordAction {
    private AuctionRecordService auctionRecordService;
    @Autowired
    public void setAuctionRecordService(AuctionRecordService auctionRecordService) {
        this.auctionRecordService = auctionRecordService;
    }

    private AuctionRecord ar;
    private Integer auctionId;
    private Map<String,Object> map = new HashMap<>();

    public Map<String, Object> getMap() {
        return map;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    public Integer getAuctionId() {
        return auctionId;
    }

    public void setAuctionId(Integer auctionId) {
        this.auctionId = auctionId;
    }

    public AuctionRecord getAr() {
        return ar;
    }

    public void setAr(AuctionRecord ar) {
        this.ar = ar;
    }


    public String addAuctionRecord(){
        System.out.println("添加一条竞拍记录的参数"+ar);
        int i = auctionRecordService.insertRecord(ar);
        map.put("add",i);
        return "addOk";
    }
    public String showAuctionRecord(){
        System.out.println("加载页面后展示竞拍记录的参数"+auctionId);
        List<AuctionRecord> auctionRecords = auctionRecordService.selectByAuctionId(auctionId);
        map.put("show",auctionRecords);
        return "showOk";
    }
    public String selectMaxPrice(){
        Double maxPrice = auctionRecordService.selectMaxAuctionRecordPrice(auctionId);
        map.put("max",maxPrice);
        return "maxPriceOk";
    }
}
